home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Development Kits / HyperCard Related / APDA HyperCard Toolkits / HyperCard CTB Toolkit 1.0b2 / Source Code / CTBKill.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  1.9 KB  |  79 lines  |  [TEXT/MPS ]

  1. (*
  2.     CTBKill [inOutBoth] -- Kill pending communication on the input (inOutBoth = "in"), output
  3.         (inOutBoth = "out") or both (inOutBoth = "both"). The default is "both".
  4.  
  5.     To compile and link this file using Macintosh Programmer's Workshop,
  6.  
  7.         pascal -w CTBKill.p
  8.         link -m ENTRYPOINT -o HyperCommands -rt XCMD=2762 -sn Main=CTBKill ∂
  9.             CTBKill.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
  10.  
  11.     © Copyright 1990 by Apple Computer, Inc.
  12.  
  13.     Initial coding 2/90 by Harry R. Chesley.
  14. *)
  15.  
  16. {$R-}
  17.  
  18. {$S CTBKill }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. procedure CTBKill(paramPtr: XCmdPtr); forward;
  31.  
  32. procedure EntryPoint(paramPtr: XCmdPtr);
  33.  
  34.     begin
  35.         CTBKill(paramPtr);
  36.     end;
  37.  
  38. procedure CTBKill(paramPtr: XCmdPtr);
  39.  
  40.     {$I CTBUtil.inc}
  41.  
  42.     var ch: Char;
  43.         killInput, killOutput: boolean;
  44.         dummy: CMErr;
  45.  
  46.     procedure Fail(errMsg: Str255); { set theResult and quit }
  47.         begin
  48.             paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
  49.             exit(CTBKill);
  50.         end;
  51.  
  52.     begin
  53.         { Check the parameter count. }
  54.         if paramPtr^.paramCount > 1 then Fail('Invalid parameter count');
  55.  
  56.         { Figure out what we're supposed to kill. }
  57.         killInput := true;
  58.         killOutput := true;
  59.         if ParmPresent(1) then
  60.             begin
  61.                 ch := Chr(paramPtr^.params[1]^^);
  62.                 if (ch = 'i') or (ch = 'I') then killOutput := false
  63.                 else if (ch = 'o') or (ch = 'O') then killInput := false;
  64.             end;
  65.  
  66.         { Make sure the Comm Toolbox is here. }
  67.         CTBReady;
  68.         { And a connection tool is present. }
  69.         EnsurePresent(connectionTool);
  70.         { And the connection is open. }
  71.         EnsureOpen;
  72.  
  73.         { kill kill kill kill Kill KIll KILl KILL KILL KILL KILL !!!!!! }
  74.         if killInput then dummy := CMIOKill(Globals^^.connHand,ord(cmDataIn));
  75.         if killOutput then dummy := CMIOKill(Globals^^.connHand,ord(cmDataOut));
  76.     end;
  77.  
  78. end.
  79.